<!DOCTYPE html>
<html>
    <head>
        <title>Web Share</title>
        <script>
            function initiate_share() {
                if (navigator.share === undefined) {
                    window.document.title = 'Fail: navigator.share === undefined';
                    return;
                }

                let data = {files: []};
                const fileBits = ['*'.repeat(26 * 1024 * 1024)];
                const options = {type: 'text/plain'};
                for (let index = 0; index < 2; ++index) {
                    let fileName = 'sample' + index + '.txt';
                    data.files.push(new File(fileBits, fileName, options));
                }
                navigator.share(data).then(() => {
                    window.document.title = 'Success';
                }).catch(e => {
                    window.document.title = 'Fail: ' + e;
                });
            }

            window.addEventListener('load', () => {
                window.addEventListener('click', initiate_share);
            });
        </script>
    </head>
    <body>
        WebShare Test!
    </body>
</html>
